package com.shanzmoo.merchant.manage.api.web.member;

import com.shanzmoo.base.bean.PageReqBase;
import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.member.domain.dto.MemberCardConfigDTO;
import com.shanzmoo.db.module.member.domain.dto.MemberMerchantRechargeDTO;
import com.shanzmoo.db.module.member.domain.dto.MemberMerchantStatusChangeDTO;
import com.shanzmoo.db.module.member.domain.dto.MemberMerchantVerifyDTO;
import com.shanzmoo.db.module.member.domain.query.MemberActivityPageQuery;
import com.shanzmoo.db.module.member.domain.query.MemberCouponConfigPageQuery;
import com.shanzmoo.db.module.member.domain.query.MemberMerchantIdPageQuery;
import com.shanzmoo.db.module.member.domain.query.MemberQuery;
import com.shanzmoo.db.module.member.domain.vo.*;
import com.shanzmoo.db.module.merchant.domain.dto.MerchantSmsInfoDto;
import com.shanzmoo.merchant.manage.api.manager.MemberMerchantManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "商户管理系统-商户会员管理")
@RestController
@RequestMapping("/merchant/member")
public class MemberMerchantController {
    @Autowired
    private MemberMerchantManager memberMerchantManager;

    @ApiOperation(value = "商户会员分页列表")
    @PostMapping("/list")
    public SHttpResponse<PageRespBase<MemberMerchantVO>> memberMerchantList(@RequestBody MemberQuery query) {

        return memberMerchantManager.getMemberMerchantListPage(query);
    }
    @ApiOperation(value = "平台充值")
    @PostMapping("/recharge")
    public SHttpResponse<Boolean> merchantMemberRecharge(@Valid @RequestBody MemberMerchantRechargeDTO request) {
        return memberMerchantManager.merchantMemberRecharge(request);
    }
    @ApiOperation(value = "平台核销")
    @PostMapping("/verify")
    public SHttpResponse<Boolean> merchantMemberVerify(@RequestBody MemberMerchantVerifyDTO request) {
        return memberMerchantManager.merchantMemberVerify(request);
    }
    @ApiOperation(value = "会员状态修改")
    @PostMapping("/staus/update")
    public SHttpResponse<Boolean> merchantMemberVerify(@Valid @RequestBody MemberMerchantStatusChangeDTO request) {
        return memberMerchantManager.memberMerchantStatusChange(request);
    }
    @ApiOperation(value = "商户会员详情")
    @GetMapping("/detail")
    public SHttpResponse<MemberMerchantDetailVO> memberMerchantDetail(@RequestParam(value = "id") Integer id) {

        return memberMerchantManager.getMemberMerchantDetail(id);
    }
    @ApiOperation(value = "商户会员详情-会员卡交易记录")
    @PostMapping("/trans/list")
    public SHttpResponse<PageRespBase<MemberAccountRecordVO>> memberMerchantTransList(@RequestBody MemberMerchantIdPageQuery request) {
        return memberMerchantManager.getMemberMerchantTransList(request);
    }
    @ApiOperation(value = "商户会员详情-积分变动记录")
    @PostMapping("/score/list")
    public SHttpResponse<PageRespBase<MemberAccountScoreRecordVO>> memberMerchantScoreList(@RequestBody MemberMerchantIdPageQuery request) {
        return memberMerchantManager.getMemberMerchantScoreList(request);
    }
    @ApiOperation(value = "会员卡管理，保存")
    @PostMapping("/card/config/save")
    public SHttpResponse<Boolean> cardConfigSave(@RequestBody MemberCardConfigDTO request) {
        return memberMerchantManager.saveCardConfig(request);
    }
    /*@ApiOperation(value = "会员卡管理删除")
    @GetMapping("/card/config/delete")
    public SHttpResponse<Boolean> cardConfigDelete(@RequestParam Integer id) {
        return memberMerchantManager.cardConfigDelete(id);
    }*/
    @ApiOperation(value = "会员卡管理，查看当前商户会员卡配置")
    @GetMapping("/card/config/detail")
    public SHttpResponse<MemberCardConfigDTO> cardConfigDetail() {
        return memberMerchantManager.cardConfigDetail();
    }
    @ApiOperation(value = "会员活动列表")
    @PostMapping("/activity/list")
    public SHttpResponse<PageRespBase<MemberActivityConfigVO>> activityList(@RequestBody MemberActivityPageQuery request) {
        return memberMerchantManager.getActivityList(request);
    }
    @ApiOperation(value = "会员活动详情")
    @GetMapping("/activity/detail")
    public SHttpResponse<MemberActivityConfigVO> activityList(@RequestParam Integer id) {
        return memberMerchantManager.getActivityDetail(id);
    }
    @ApiOperation(value = "会员活动保存")
    @PostMapping("/activity/save")
    public SHttpResponse<Boolean> activitySave(@Valid @RequestBody MemberActivityConfigVO request) {
        return memberMerchantManager.saveActivity(request);
    }
    @ApiOperation(value = "活动配置删除")
    @GetMapping("/activity/delete")
    public SHttpResponse<Boolean> activityDelete(@RequestParam Integer id) {
        return memberMerchantManager.deleteActivityConfig(id);
    }
    @ApiOperation(value = "优惠券列表")
    @PostMapping("/coupon/list")
    public SHttpResponse<PageRespBase<MemberCouponConfigVO>> couponList(@RequestBody MemberCouponConfigPageQuery request) {
        return memberMerchantManager.getCouponList(request);
    }
    @ApiOperation(value = "优惠券详情")
    @GetMapping("/coupon/detail")
    public SHttpResponse<MemberCouponConfigVO> couponDetail(@RequestParam Integer id) {
        return memberMerchantManager.getCouponDetail(id);
    }
    @ApiOperation(value = "优惠券配置保存")
    @PostMapping("/coupon/save")
    public SHttpResponse<Boolean> couponConfigSave(@RequestBody MemberCouponConfigVO request) {
        return memberMerchantManager.saveCouponConfig(request);
    }
    @ApiOperation(value = "优惠券配置删除")
    @GetMapping("/coupon/delete")
    public SHttpResponse<Boolean> couponConfigSave(@RequestParam Integer id) {
        return memberMerchantManager.deleteCouponConfig(id);
    }
    /**
     *
     *
     * @return
     */
    @ApiOperation(value = "会员卡管理-发送短信信息")
    @GetMapping("/sendSmsMsg")
    public SHttpResponse<Boolean> sendSmsMsg() {
        return memberMerchantManager.sendSmsMsg();
    }
}
